From: Alexander Mikhaylenko Date: Fri, 16 Apr 2021 14:17:33 +0000 (+0500) Subject: background: Check xml mime type instead of extension X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~616^2^2~59 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=58ed969d;p=gnome-shell.git background: Check xml mime type instead of extension This is required to be able to set animated wallpapers with the wallpaper portal, which names them 'background' without an extension. See https://gitlab.gnome.org/bertob/nostalgia/-/merge_requests/12 Part-of: --- diff --git a/js/ui/background.js b/js/ui/background.js index df2d98112..1f7c5e572 100644 --- a/js/ui/background.js +++ b/js/ui/background.js @@ -101,6 +101,8 @@ const LoginManager = imports.misc.loginManager; const Main = imports.ui.main; const Params = imports.misc.params; +Gio._promisify(Gio._LocalFilePrototype, 'query_info_async', 'query_info_finish'); + var DEFAULT_BACKGROUND_COLOR = Clutter.Color.from_pixel(0x2e3436ff); const BACKGROUND_SCHEMA = 'org.gnome.desktop.background'; @@ -479,8 +481,15 @@ var Background = GObject.registerClass({ } } - _loadFile(file) { - if (file.get_basename().endsWith('.xml')) + async _loadFile(file) { + const info = await file.query_info_async( + Gio.FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, + Gio.FileQueryInfoFlags.NONE, + 0, + null); + + const contentType = info.get_content_type(); + if (contentType === 'application/xml') this._loadAnimation(file); else this._loadImage(file);